//
//  StatusesOriginalView.swift
//  新浪微博
//
//  Created by mac on 15/12/1.
//  Copyright © 2015年 mac. All rights reserved.
//

import UIKit
import SnapKit
import SDWebImage

class StatusesOriginalView: UIView {
    override init(frame: CGRect) {
        super.init(frame: frame)
//        backgroundColor = UIColor.darkGrayColor()
        setupUI()
    }
//添加模型属性
    var status: Statues?{
        didSet{
            //绑定数据
            headImage.sd_setImageWithURL(status?.user?.headImageURL, placeholderImage: UIImage(named: "avatar_default_big"))
            nameLabel.text = status?.user?.name
            mbrankimage.image = status?.user?.mbrankImage
            verified_type_image.image = status?.user?.verified_type_image
            timeLabel.text = status?.created_at
            sourceLabel.text = status?.source
            contentLabel.text = status?.text
            
            //设置配图视图的图盘效果
            pictureView.imageURLs = (status?.imageURLs)!
        
        }
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    //设置ui verified_type_image
    private func setupUI(){
    addSubview(headImage)
    addSubview(nameLabel)
    addSubview(mbrankimage)
    addSubview(verified_type_image)
    addSubview(timeLabel)
    addSubview(sourceLabel)
    addSubview(contentLabel)
    addSubview(pictureView)
        //设置布局
        headImage.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(self).offset(StatusesCellMargin)
            make.top.equalTo(self).offset(StatusesCellMargin)
            make.size.equalTo(CGSizeMake(StatusesCellWidth, StatusesCellWidth))
        }
        nameLabel.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(headImage.snp_right ).offset(StatusesCellMargin)
            make.top.equalTo(headImage.snp_top)
        }
       mbrankimage.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(nameLabel.snp_right).offset(StatusesCellMargin)
            make.top.equalTo(nameLabel.snp_top)

        }
        verified_type_image.snp_makeConstraints { (make) -> Void in
            make.centerX.equalTo(headImage.snp_right)
            make.centerY.equalTo(headImage.snp_bottom)
            
        }
        timeLabel.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(headImage.snp_right).offset(StatusesCellMargin)
            make.bottom.equalTo(headImage.snp_bottom)
            
        }
       sourceLabel.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(timeLabel.snp_right).offset(StatusesCellMargin)
            make.top.equalTo(timeLabel.snp_top)
            
        }
        contentLabel.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(self.snp_left).offset(StatusesCellMargin)
            make.top.equalTo(headImage.snp_bottom).offset(StatusesCellMargin)
            
        }
        pictureView.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(contentLabel.snp_left)
            make.top.equalTo(contentLabel.snp_bottom).offset(StatusesCellMargin)
            make.size.equalTo(CGSize(width: 100, height: 100))
            
        }

        
       self.snp_makeConstraints { (make) -> Void in
            make.bottom.equalTo(pictureView.snp_bottom).offset(StatusesCellMargin)
        }



 
    }
   //懒加载所有的子视图 头像
    private lazy var headImage: UIImageView = UIImageView(image: UIImage(named: "avatar_default_big"))
    //用户名
    private lazy var nameLabel: UILabel = UILabel(labeltext: "图图123", color: UIColor.darkGrayColor(), fontsize: 14)
    //用户等级
     private lazy var mbrankimage: UIImageView = UIImageView(image: UIImage(named: "common_icon_membership"))
    //用户认证类型
    private lazy var verified_type_image: UIImageView = UIImageView(image: UIImage(named: "avatar_enterprise_vip"))
    //时间
    private lazy var timeLabel: UILabel = UILabel(labeltext: "10:12", color: UIColor.orangeColor(), fontsize: 12)
    //来源
    private lazy var sourceLabel: UILabel = UILabel(labeltext: "隔壁老王", color: UIColor.darkGrayColor(), fontsize: 14)
    //正文
    private lazy var contentLabel: UILabel = UILabel(labeltext: "我是你一个好人我是你一个好人我是你一个好人我是你一个好人我是你一个好人我是你一个好人我是你一个好人我是你一个好人我是你一个好人我是你一个好人我是你一个好人我是你一个好人我是你一个好人我是你一个好人我是你一个好人我是你一个好人", color: UIColor.darkGrayColor(), fontsize: 14,margin: StatusesCellMargin)
    //配图视图
    private lazy var pictureView: StatusesPictureView = StatusesPictureView()


}
